//点击已处理
$(function(){
	//话务量
	queryCountTelephone();
	//满意度
	querySatisfactionData();
	//平均通话时长
	queryAverageCallTime();
	//质检均分
	queryQcScoreData();

});

//“满意度排名”	
function querySatisfactionData(){
	// “满意度排名”
	$.ajax({	
      url: CCS_SERVER_NAME+"call-web/callin/querySatisfactionData.action",
      type: "GET",
      data:{ 
      	'callServiceVo.callServiceEntity.createUser': userInfo.empCode  //userInfo.empCode '199221'
        },
	        success: function (data) {
	        	
	        	if(data.callServiceVo==null || data.callServiceVo==undefined ) {
	        		return;
	        	}
	        	$("#querySatisfactionData").empty();
	        	
	        	if(data.callServiceVo.satisfactionDataList.length==0){
	        		var str = '<tr>'+
        			'<td><div class="rank">'+''+'</div></td>'+
        			'<td><p>'+'暂无数据'+'</td>'+
        			'<td><p>'+'暂无数据'+'</td>'+
        			'<td><p>'+'0'+'</td>'+
        			'</tr>';
        			$("#querySatisfactionData").append(str);
	        	}
	        	var satisfactionData=null;
	        	if(data.callServiceVo.satisfactionDataList.length==5){
	        		for (var i = 0; i <=4; i++) {
	        			satisfactionData = convertNumber(data.callServiceVo.satisfactionDataList[i].satisfaction);
	        			var str = '<tr>'+
	        			'<td><div class="rank">'+data.callServiceVo.satisfactionDataList[i].rank+'</div></td>'+
	        			'<td><p>'+data.callServiceVo.satisfactionDataList[i].name+'</td>'+
	        			'<td><p>'+data.callServiceVo.satisfactionDataList[i].deptName+'</td>'+
	        			'<td><p>'+satisfactionData+'</td>'+
	        			'</tr>';
	        			$("#querySatisfactionData").append(str);
	        			 
	        			if(data.callServiceVo.satisfactionDataList[i].empNo==userInfo.empCode){
	        				$("#mysatisfyRank").html(data.callServiceVo.satisfactionDataList[i].rank);
	        				$("#mysatisfy").html(data.callServiceVo.satisfactionDataList[i].satisfaction);
	        			}
	        		}
	        		
	        	}else if(data.callServiceVo.satisfactionDataList.length==6){
	        		for (var i = 0; i <=4; i++) {
	        			satisfactionData = convertNumber(data.callServiceVo.satisfactionDataList[i].satisfaction);
	        			var str = '<tr>'+
	        			'<td><div class="rank">'+data.callServiceVo.satisfactionDataList[i].rank+'</div></td>'+
	        			'<td><p>'+data.callServiceVo.satisfactionDataList[i].name+'</td>'+
	        			'<td><p>'+data.callServiceVo.satisfactionDataList[i].deptName+'</td>'+
	        			'<td><p>'+satisfactionData+'</td>'+
	        			'</tr>';
	        			$("#querySatisfactionData").append(str);
	        		}
	        		$("#mysatisfyRank").html(data.callServiceVo.satisfactionDataList[5].rank);
	        		$("#mysatisfy").html(data.callServiceVo.satisfactionDataList[5].satisfaction.toFixed(2));
	        		
	        	}

	        },
	        error: function (httpRequest) {
	        	console.log("未知异常");
	        }
	    });
}

//"话务量"
function queryCountTelephone(){
	
//"话务量"
	$.ajax({	
      url: CCS_SERVER_NAME+"call-web/callin/queryCountTelephone.action",
      type: "GET",
      data:{ 
      	'callServiceVo.callServiceEntity.createUser': userInfo.empCode  //userInfo.empCode '199221'
        },
	        success: function (data) {
	        	
	        	if(data.callServiceVo==null || data.callServiceVo==undefined ) {
	        		return;
	        	}
	        	
	        	$("#queryCountTelephone").empty();
	        	if(data.callServiceVo.satisfactionDataList.length==0){
	        		var str = '<tr>'+
        			'<td><div class="rank">'+''+'</div></td>'+
        			'<td><p>'+'暂无数据'+'</td>'+
        			'<td><p>'+'暂无数据'+'</td>'+
        			'<td><p>'+'0'+'</td>'+
        			'</tr>';
        			$("#queryCountTelephone").append(str);
	        	}
	        	if(data.callServiceVo.satisfactionDataList.length==5){
	        		for (var i = 0; i <=4; i++) {
	        			var str = '<tr>'+
	        			'<td><div class="rank">'+data.callServiceVo.satisfactionDataList[i].rank+'</div></td>'+
	        			'<td><p>'+data.callServiceVo.satisfactionDataList[i].name+'</td>'+
	        			'<td><p>'+data.callServiceVo.satisfactionDataList[i].deptName+'</td>'+
	        			'<td><p>'+data.callServiceVo.satisfactionDataList[i].countTelephone+'</td>'+
	        			'</tr>';
	        			$("#queryCountTelephone").append(str);
	        			 
	        			if(data.callServiceVo.satisfactionDataList[i].empNo==userInfo.empCode){
	        				$("#countTelephoneRank").val(data.callServiceVo.satisfactionDataList[i].rank);
	        				$("#myTelephoneNum").val(data.callServiceVo.satisfactionDataList[i].countTelephone);
	        			}
	        		}
	        		
	        	}else if(data.callServiceVo.satisfactionDataList.length==6){
	        		
	        		for (var i = 0; i <=4; i++) {
	        			var str = '<tr>'+
	        			'<td><div class="rank">'+data.callServiceVo.satisfactionDataList[i].rank+'</div></td>'+
	        			'<td><p>'+data.callServiceVo.satisfactionDataList[i].name+'</td>'+
	        			'<td><p>'+data.callServiceVo.satisfactionDataList[i].empNo+'</td>'+
	        			'<td><p>'+data.callServiceVo.satisfactionDataList[i].countTelephone+'</td>'+
	        			'</tr>';
	        			$("#queryCountTelephone").append(str);
	        		}
	        		$("#countTelephoneRank").html(data.callServiceVo.satisfactionDataList[5].rank);
	        		$("#myTelephoneNum").html(data.callServiceVo.satisfactionDataList[5].countTelephone);
	        		
	        	}
	        	//实现页面滚动
	        	$('#myCarousel-cc').carousel({interval:5000});
	        },
	        error: function (httpRequest) {
	        	console.log("未知异常");
	        }
	    });
}	



//平均通话时长的 	
function queryAverageCallTime(){
	
	//平均通话时长的 
	$.ajax({	
      url: CCS_SERVER_NAME+"call-web/callin/queryAverageCallTime.action",
      type: "GET",
      data:{ 
 		  'callServiceVo.callServiceEntity.createUser': userInfo.empCode //userInfo.empCode '199221'
        },
	        success: function (data) {
	        	
		        	if(data.callServiceVo==null || data.callServiceVo==undefined ) {
		        		return;
		        	}
		        	$("#queryAverageCallTime").empty();
		        	if(data.callServiceVo.satisfactionDataList.length==0){
		        		var str = '<tr>'+
	        			'<td><div class="rank">'+''+'</div></td>'+
	        			'<td><p>'+'暂无数据'+'</td>'+
	        			'<td><p>'+'暂无数据'+'</td>'+
	        			'<td><p>'+'0'+'</td>'+
	        			'</tr>';
	        			$("#queryAverageCallTime").append(str);
		        	}
		        	
		        	if(data.callServiceVo.satisfactionDataList.length==5){
		        		for (var i = 0; i <=4; i++) {
		        			var str = '<tr>'+
		        			'<td><div class="rank">'+data.callServiceVo.satisfactionDataList[i].rank+'</div></td>'+
		        			'<td><p>'+data.callServiceVo.satisfactionDataList[i].name+'</td>'+
		        			'<td><p>'+data.callServiceVo.satisfactionDataList[i].deptName+'</td>'+
		        			'<td><p>'+data.callServiceVo.satisfactionDataList[i].averCallDuration+'</td>'+
		        			'</tr>';
		        			$("#queryAverageCallTime").append(str);
		        			 
		        			if(data.callServiceVo.satisfactionDataList[i].empNo==userInfo.empCode){
		        				$("#myRank").val(data.callServiceVo.satisfactionDataList[i].rank);
		        				$("#averageCallTime").val(data.callServiceVo.satisfactionDataList[i].AverageCallTime);
		        			}
		        		}
		        		
		        	}else if(data.callServiceVo.satisfactionDataList.length==6){
		        		for (var i = 0; i <=4; i++) {
		        			var str = '<tr>'+
		        			'<td><div class="rank">'+data.callServiceVo.satisfactionDataList[i].rank+'</div></td>'+
		        			'<td><p>'+data.callServiceVo.satisfactionDataList[i].name+'</td>'+
		        			'<td><p>'+data.callServiceVo.satisfactionDataList[i].deptName+'</td>'+
		        			'<td><p>'+data.callServiceVo.satisfactionDataList[i].averCallDuration+'</td>'+
		        			'</tr>';
		        			$("#queryAverageCallTime").append(str);
		        		}
		        		$("#myRank").html(data.callServiceVo.satisfactionDataList[5].rank);
		        		$("#averageCallTime").html(data.callServiceVo.satisfactionDataList[5].averCallDuration);
		        		
		        	}
	        	

	        },
	        error: function (httpRequest) {
	        	console.log("未知异常");
	        }
	       
	    });	
	
}	



//"质检均分"
function queryQcScoreData(){
	$.ajax({	
      url: CCS_SERVER_NAME+"call-web/callin/queryQcScoreData.action",
      type: "GET",
      data:{ 
      	'callServiceVo.callServiceEntity.createUser': userInfo.empCode   //userInfo.empCode '199221'
        },
	        success: function (data) {

	        	if(data.callServiceVo==null || data.callServiceVo==undefined ) {
	        		return;
	        	}
	        	
	        	$("#queryQcScoreData").empty();
	        	if(data.callServiceVo.qcScoreList.length==0){
	        		var str = '<tr>'+
        			'<td><div class="rank">'+''+'</div></td>'+
        			'<td><p>'+'暂无数据'+'</td>'+
        			'<td><p>'+'暂无数据'+'</td>'+
        			'<td><p>'+'0'+'</td>'+
        			'</tr>';
        			$("#queryQcScoreData").append(str);
	        	}
	        	var qcScoreListData =null;
	        	
	        	if(data.callServiceVo.qcScoreList.length==5){
	        		
	        		for (var i = 0; i <=4; i++) {
	        			qcScoreListData = convertNumber(data.callServiceVo.qcScoreList[i].avgScore);
	        			var str = '<tr>'+
	        			'<td><div class="rank">'+data.callServiceVo.qcScoreList[i].rank+'</div></td>'+
	        			'<td><p>'+data.callServiceVo.qcScoreList[i].name+'</td>'+
	        			'<td><p>'+data.callServiceVo.qcScoreList[i].deptName+'</td>'+
	        			'<td><p>'+qcScoreListData+'</td>'+
	        			'</tr>';
	        			$("#queryQcScoreData").append(str);
	        			 
	        			if(data.callServiceVo.qcScoreList[i].empNo==userInfo.empCode){
	        				$("#myQcScoreRank").val(data.callServiceVo.qcScoreList[i].rank);
	        				$("#qcScoreData").val(data.callServiceVo.qcScoreList[i].avgScore);
	        			}
	        		}
	        		
	        	}else if(data.callServiceVo.qcScoreList.length==6){
	        		for (var i = 0; i <=4; i++) {
	        			qcScoreListData = convertNumber(data.callServiceVo.qcScoreList[i].avgScore);
	        			var str = '<tr>'+
	        			'<td><div class="rank">'+data.callServiceVo.qcScoreList[i].rank+'</div></td>'+
	        			'<td><p>'+data.callServiceVo.qcScoreList[i].name+'</td>'+
	        			'<td><p>'+data.callServiceVo.qcScoreList[i].deptName+'</td>'+
	        			'<td><p>'+qcScoreListData+'</td>'+
	        			'</tr>';
	        			$("#queryQcScoreData").append(str);
	        		}
	        		$("#myQcScoreRank").html(data.callServiceVo.qcScoreList[5].rank);
	        		$("#qcScoreData").html(data.callServiceVo.qcScoreList[5].avgScore);
	        		
	        	}
//	        	//实现页面滚动
//	        	$('#myCarousel-cc').carousel({interval:5000});

	        },
	        error: function (httpRequest) {
	        	console.log("未知异常");
	        }
	    });	
}


function convertNumber(obj) {
	
	if(obj.toString().indexOf(".") <= 0){
		return window.parseFloat(obj += ".00").toFixed(2);
	}else{
		return obj.toFixed(2);
	}
}